//
//  XMBaseView.m
//  XMJJ_zml
//
//  Created by apple on 2025/5/8.
//

#import "XMBaseView.h"

@implementation XMBaseView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self baseInit];
    }
    return self;
}

- (void)baseInit {
    self.backgroundColor = kColorHEX(0xffffff);
}

- (void)backAction:(UIButton *)button {
    [self.viewController.navigationController popViewControllerAnimated:YES];
}

- (UIView *)navView {
    if (!_navView) {
        _navView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, kNavagationBarH)];
        _navView.backgroundColor = kColorHEX(0xF0F0F0);
        
        _backBtn = [UIButton buttonWithType:UIButtonTypeCustom frame:CGRectMake(0, kNavagationBarH - 44, 44, 44) image:@"back_icon_black" selectImg:@"back_icon_black"];
        [_backBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
        [_navView addSubview:_backBtn];
        
        _navTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(44, kNavagationBarH - 44, self.width - 44*2, 44) font:KFontSize(18.0) textColor:kColorHEX(0x000000) textAlignment:NSTextAlignmentCenter];
        [_navView addSubview:_navTitleLabel];
    }
    return _navView;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
